<!-- /*
 * @Author: 谢力 843926058@qq.com
 * @Date:   2019-11-06
 * @Last Modified by:   谢力
 * @Last Modified time: 2019-11-07
 */ -->
<template>
    <div class="ui-mode-box flex-col">
        <div class="mt-tab-inner relative flex1">
            <div class="ui-mode-box body" ref="scroll">
                <div class="relative" v-if="user_quan_list&&user_quan_list.length">
                    <div class="coupon-wrap">
                        <div class="coupon-item"
                            :key="`coupon-${i}`"
                            v-for="(item,i) in user_quan_list">
                            <div class="coupon-info flex-row align-center-row">
                                <div class="coupon-price flex-col align-center-row">
                                    <div class="coupon-minus"><span>¥</span>{{item.value_4_use_rule}}</div>
                                    <div>满{{item.key_4_use_rule}}元可用</div>
                                </div>
                                <div class="coupon-content flex-row align-center-row align-between-row">
                                    <div class="coupon-rules">
                                        <div class="coupon-name">
                                            <p>满{{item.key_4_use_rule}}元减{{item.value_4_use_rule}}元</p>
                                            <p>仅可购买店铺内部分产品</p>
                                        </div>
                                        <div class="coupon-time">{{item.time_begin.replace(/-/g,".").split(' ')[0]}} 至 {{item.time_end.replace(/-/g,".").split(' ')[0]}} 可用</div>
                                    </div>
                                    <div class="coupon-label expire"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div v-if="isScrolling" class="flex1 flex-row align-center scrolling-content relative">
                        <span class="icon">
                            <bsx-loading master-background="rgba(0,0,0,0)" box-background="rgba(0,0,0,0)" :size="35" :show-text="false"></bsx-loading>
                        </span>
                        <span class="text">努力加载中...</span>
                    </div>
                    <div v-else-if="isLoadEnded" class="flex1 flex-row align-center scrolling-content relative">已经到底啦~~</div>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
import mixinCommon from '../../../mixins/common';
import mixinRequest from '../../../mixins/request';
export default {
    name:'cart/coupon/expire',
    data(){
        return {
            public_agent_info:{},
            public_user_info:{},
            user_quan_list:[],
            selected_index:''
        };
    },
    mixins:[
        mixinCommon,
        mixinRequest
    ],
    computed:{
    },
    watch:{
        resourceLoaded:{
            handler(flag){
                flag&&this.$nextTick(this.init);
            },
            immediate:true
        }
    },
    created(){
    },
    mounted(){
    },
    methods:{
        // 初始化
        init(){
            this.getListInfo({
                flag:true,
                page:0
            });
        },
        // 获取列表数据
		getListInfo({flag,page,callback}){
            this.getPageInfo({
                name:'my.coupon',
                param:{
                    invoke_method:'score_list_4_one_user',
                    id_public_agent_info_list_like:this.$store.state.global.userInfo.id_public_agent_info,
                    pre_db_para_begin_idx:0,
                    pre_db_para_length_4_list:1000,
                    type_4_score_display:2,
                    pre_cmd_para_load_goods:false,
                    'public_score_record.is_online':2
                }
            }).then(({result,response})=>{
                if(result.public_score_list&&result.public_score_list.length){
                    this.user_quan_list.push(...result.public_score_list.slice(0, this.pageSize));
                    this.currentPage = page;
                    if (result.public_score_list.length < this.pageSize) {
                        this.isLoadEnded = true;
                    } else if ((this.currentPage + 1) * this.pageSize >= parseInt(result.result_num)) {
                        this.isLoadEnded = true;
                    };
                    callback&&callback();
                }else{
                    if(flag){
                        this.showResult('没有查询到相关数据');
                    }else{
                        this.showToast('没有查询到相关数据',false);
                    };
                    callback&&callback();
                };
            }).catch(({msg})=>{
                this.showMessage(msg);
            });
		},
        // 请求失败刷新
        handleRefresh(){
            this.init();
        }
    },
    components:{
    },
    beforeDestroy(){
    }
}
</script>
<style lang="less" scoped>
</style>
